package com.swpu.eduservice.controller;
import com.swpu.commonutils.R;
import com.swpu.eduservice.entity.Subject.OneSubject;
import com.swpu.eduservice.service.EduSubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
/**
 * 课程科目 前端控制器
 * @author ygq
 * @since 2021-10-15
 */
@RestController
@CrossOrigin
@RequestMapping("/eduservice/edu-subject")
public class EduSubjectController {

    @Autowired
    private EduSubjectService eduSubjectService;


    //添加课程分类
    //获取上传的文件 把文件的内容读取出来
    @PostMapping("/addSubject")
    public R addSubject(MultipartFile file){
        eduSubjectService.saveSubject(file,eduSubjectService);
        return R.ok();

    }

    @GetMapping("/getAllSubject")
    public R getAllSubject(){
        List<OneSubject> list  = eduSubjectService.getAllSubject();
        return R.ok().data("list",list);
    }

}

